;; Demonstration of let* special form

;; Basic let* example
(display "Basic let* example:")
(newline)
(let* ((x 2) (y (* x 3))) 
  (+ x y))
(newline)

;; let* with sequential bindings where later bindings refer to earlier ones
(display "Sequential bindings:")
(newline)
(let* ((x 1) 
       (y (+ x 1)) 
       (z (+ y 1)))
  (list x y z))
(newline)

;; let* vs let comparison
(display "let* vs let comparison:")
(newline)
(display "let* result: ")
(let* ((x 2) (y (* x 3)))
  (+ x y))
(newline)

(display "let result: ")
(let ((x 2) (y (* x 3)))  ; This will cause an error because x is not defined in the let scope when evaluating (* x 3)
  (+ x y))
(newline)